const {request} = require('./request')

module.exports = {
  // 请求欢迎页面轮播图
  getBannerApp(type='app'){
    return request('banner/list',{type:type},'GET')
  },
  // 请求首页轮播图
  getBannerApi(type='index'){
    return request('banner/list',{type:type},'GET')
  },
  // 分类
  getCartList(){
    return request('shop/goods/category/all','','GET')
  },

  // 公告接口
  getNotice(){
    return request('/notice/list','','GET')
  },

  // 优惠咨询下的直播广告
  getBroadcast(key='index-live-pic'){
    return request('/site/adPosition/info',{key:key},'GET')
  },

  // 秒杀数据
  getSeckillCom(miaosha=true){
    return request('/shop/goods/list/v2',{miaosha:miaosha},'POST')
  },

  // 爆品推荐
  getRecommend(recommendStatus=1){
    return request('/shop/goods/list/v2',{recommendStatus:recommendStatus},'POST')
  },

  // 疯狂砍价
  getBargain(kanjia=true){
    return request('/shop/goods/list/v2',{kanjia:kanjia},'POST')
  },

  // 拼团
  getGroup(pingtuan=true){
    return request('/shop/goods/list/v2',{pingtuan:pingtuan},'POST')
  },

  // 商品列表
  getProductList(){
    // console.log(a ,b ,c)
    return request('/shop/goods/list/v2','' ,'POST')
  },
  // 商品详情
  getGoodsDetail(id){
    return request('shop/goods/detail',{id:id},'GET')
  },
  // 商品评价
  getGoodsAppraise(goodsId){
    return request('tz/shop/goods/reputation/v2',{goodsId:goodsId},'POST',false)
  },
  // 搜索
  getSearchGoodsList(infor){
    return request('tz/shop/goods/list/v2',{k:infor},'POST', false)
  },

  // 新品排序
  getNewSorting({infor,orderBy=''}){
    return request('tz/shop/goods/list/v2',{k:infor,orderBy:orderBy},'POST', false)
  },



  // 判断token是否有效接口
  getTokenAPI(token){
    return request('user/check-token',{token},'GET')
  },
  // 登录接口，把wx.login的res.code传过来
  getLoginApi(code, token){
    console.log(code)
    return request('user/wxapp/authorize',{code, token},'POST')
  },

  // 获取用户照片接口
  getUserInfo(token){
    return request('user/detail',{token},'GET')
  },


  // 加入购物车接口
  getAddShopping(data){
    return request('shopping-cart/add',data,'POST')
  },

  // 读取购物车数据接口
  getReadingData(token){
    return request('shopping-cart/info',{token},'GET')
  },

  // 购物车修改购买数量接口
  getPurchaseQuantity(data){
    return request('shopping-cart/modifyNumber',data,'POST')
  },

  // 购物车修改选中状态接口
  getChecked(data){
    return request('shopping-cart/select',data,'POST')
  },

  // 删除
  getDelGoods(data){
    return request('shopping-cart/remove',data,'POST')
  },

  // 收藏接口
  getcollect(data){
    return request('shop/goods/fav/add',data,'POST')
  },

  // 检测是否收藏接口
  getDetectionCollect(data){
    return request('shop/goods/fav/check',data,'GET')
  },

  // 删除收藏接口
  getDelCollect(data){
    return request('shop/goods/fav/delete',data,'POST')
  },

  // 优惠券接口
  getCoupon(){
    return request('discounts/coupons','GET')
  },

  // 广告接口
  getSkkipNotice(id){
    return request('notice/detail',id,'GET')
  },

  //读取购物车数据
  getCartLength(data){
    return request('shopping-cart/info',data,'GET')
  },

  // 获取左侧帮助
  getleftList(){
    return request('cms/category/list','GET')
  },

  // 获取右侧帮助
  getRightList(data){
    return request('cms/news/list',data,'POST')
  },

  // 获取帮助信息
  getdetail(data){
    return request('cms/news/detail',data,'GET')
  }


  // t() {
  //   return request('/shop/goods/list/v2', {page: 1, pageSize: 20, k: '衣服', orderBy: ''}, 'POST')
  // }
}